<template>
  <el-container class="layout-container">
    <el-aside width="80px" class="aside">
      <div class="logo">
        <svg width="36" height="36" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg" class="logo-img">
          <rect width="128" height="128" rx="24" fill="currentColor"/>
          <path d="M38 64C38 49.6406 49.6406 38 64 38C78.3594 38 90 49.6406 90 64C90 78.3594 78.3594 90 64 90" stroke="currentColor" stroke-width="8" stroke-linecap="round" class="logo-stroke"/>
          <path d="M64 90C49.6406 90 38 78.3594 38 64" stroke="currentColor" stroke-width="8" stroke-linecap="round" stroke-dasharray="4 6" class="logo-stroke"/>
          <circle cx="64" cy="64" r="8" fill="currentColor" class="logo-dot"/>
        </svg>
      </div>
      <div class="menu-container">
        <router-link to="/" class="menu-item" :class="{ active: route.path === '/' }">
          <el-icon><Grid /></el-icon>
          <span>应用</span>
        </router-link>
      </div>
    </el-aside>

    <el-container>
      <el-header height="60px" class="header">
        <div class="header-left">
          <el-breadcrumb>
            <el-breadcrumb-item :to="{ path: '/' }">应用中心</el-breadcrumb-item>
            <el-breadcrumb-item v-if="route.meta?.title">{{ route.meta?.title }}</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <div class="header-right">
          <el-dropdown>
            <span class="user-info">
              <el-avatar :size="32" />
              <span>管理员</span>
            </span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item @click="handleLogout">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </el-header>

      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import { ref, computed } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { Grid } from '@element-plus/icons-vue'

const router = useRouter()
const route = useRoute()

// 退出登录
const handleLogout = () => {
  router.push('/login')
}
</script>

<style scoped lang="scss">
.layout-container {
  height: 100vh;
  background-color: var(--el-bg-color);

  .aside {
    background-color: var(--el-bg-color-overlay);
    border-right: 1px solid var(--el-border-color-light);
    display: flex;
    flex-direction: column;
    
    .logo {
      height: 36px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-bottom: 1px solid var(--el-border-color-light);
      padding: 12px;
      flex-shrink: 0;

      .logo-img {
        color: var(--el-color-primary);
        
        .logo-stroke {
          stroke: var(--el-bg-color);
        }
        
        .logo-dot {
          fill: var(--el-bg-color);
        }
      }
    }

    .menu-container {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 20px 0;

      .menu-item {
        width: 56px;
        height: 56px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--el-text-color-regular);
        text-decoration: none;
        border-radius: 12px;
        transition: all 0.3s;
        margin-bottom: 8px;
        
        .el-icon {
          font-size: 24px;
          margin-bottom: 4px;
        }
        
        span {
          font-size: 12px;
        }
        
        &:hover {
          background-color: var(--el-color-primary-light-9);
          color: var(--el-color-primary);
        }
        
        &.active {
          background-color: var(--el-color-primary-light-9);
          color: var(--el-color-primary);
        }
      }
    }
  }

  .header {
    background-color: var(--el-bg-color-overlay);
    border-bottom: 1px solid var(--el-border-color-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;

    .header-right {
      .user-info {
        display: flex;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        color: var(--el-text-color-regular);
      }
    }
  }

  .el-main {
    background-color: var(--el-bg-color);
    padding: 20px;
  }
}
</style> 